App({
  
  onShow: function () {
    this.getPnToken();
  },
  onLaunch: function () {

    const { model, system, statusBarHeight } = wx.getSystemInfoSync()
    let headHeight
    if (/iphone\s{0,}x/i.test(model)) {
      headHeight = 88
    } else if (system.indexOf('Android') !== -1) {
      headHeight = 68
    } else {
      headHeight = 64
    }
    this.globalData.headerHeight = headHeight
    this.globalData.statusBarHeight = statusBarHeight
    if(!wx.getStorageSync('nickName')){
        wx.getUserInfo({
            success: res => {
                wx.setStorageSync('nickName',res.userInfo.nickName)
                wx.redirectTo({
                    url: '/pages/home/index'
                })
            }
        })
    }
  },
  isNull: function (str) {
    if (str == null || str == '' || str == undefined) {
      return true;
    }
    return false;
  },
  getPnToken() {
    var that = this;
    wx.getStorage({
      key: 'pnToken',
      success(res) {
        that.pnToken = res.data;
        //console.log(that.pnToken);
      }
    })
  },
  globalData: {
    userInfo: null,
    headerHeight: 0,
    statusBarHeight: 0,
    im_host:'http://webchat.szxxtx.com/web/api/v1/new/app'
  },
  pnToken: ''
})